<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>门店管理</title>
	<meta name="decorator" content="default"/>
	<link href="${ctxStatic}/jquery-select2/3.4/select2.min.css" rel="stylesheet" />
	<script src="https://select2.github.io/vendor/js/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
	<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$(".js-example-basic-single").select2();
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		
		var storeId='';
		//设置门店管理员
		function administrators(id){
			storeId=id;
			var href="${ctx}/jiujiu/jiuManufactor/memberList?storeId="+storeId+"&type=4";
			top.$.jBox.open('iframe:'+href,'选择用户',$(top.document).width()-800,$(top.document).height()-120,{
				buttons:{"关闭":true},
				loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
					$(".nav,.form-actions,[class=btn]", h.find("iframe").contents()).hide();
					$("body", h.find("iframe").contents()).css("margin","10px");
				}
			});
			
			//定时刷新
			 window.setInterval(function(){ 
				 if(storeId!=''){
						$.getJSON("${ctx}/jiujiu/jiuStore/getStoreIdAdmin",{storeId:storeId}, function(data){
		                    $('#guan'+storeId).html(data.name);
		                });
					}
			}, 1000);
			
			return false;
		}
		
		
		function auditing(storeId){
			$.getJSON("${ctx}/jiujiu/jiuStore/auditing",{storeId:storeId}, function(data){
               alert(data.message);
               if(data.msg=='success'){
            	   $('#s'+storeId).html('已通过');
               }
            });
		}
		
		
		
		var tiStoreId='';
		//设置提现账户
		function tixian(id){
			tiStoreId=id;
			var href="${ctx}/jiujiu/jiuManufactor/memberList?storeId="+tiStoreId+"&type=6";
			top.$.jBox.open('iframe:'+href,'选择用户',$(top.document).width()-800,$(top.document).height()-120,{
				buttons:{"关闭":true},
				loaded:function(h){
					$(".jbox-content", top.document).css("overflow-y","hidden");
					$(".nav,.form-actions,[class=btn]", h.find("iframe").contents()).hide();
					$("body", h.find("iframe").contents()).css("margin","10px");
				}
			});
			
			//定时刷新
			 window.setInterval(function(){ 
				 if(tiStoreId!=''){
						$.getJSON("${ctx}/jiujiu/jiuStore/getStoreTixian",{storeId:tiStoreId}, function(data){
							$('#tiwei'+tiStoreId).html(data.tiMemberName);
		                    $('#tizhen'+tiStoreId).html(data.tiRealName);
		                });
					}
			}, 1000);
			
			return false;
		}
		
		
		function excel(){
			$('#searchForm').attr('action',"${ctx}/jiujiu/jiuStore/excel");
			$('#searchForm').submit();
		}
		function search(){
			$('#searchForm').attr('action',"${ctx}/jiujiu/jiuStore");
			$('#searchForm').submit();
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/jiujiu/jiuStore/">门店列表</a></li>
		<shiro:hasPermission name="jiujiu:jiuStore:edit"><li><a href="${ctx}/jiujiu/jiuStore/form">门店添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="jiuStore" action="${ctx}/jiujiu/jiuStore/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>管理员昵称 ：</label><form:input path="memberName" htmlEscape="false" maxlength="50" class="input-medium"/>
		<label>认证名称 ：</label><form:input path="realName" htmlEscape="false" maxlength="50" class="input-medium"/>
		<label>身份证号 ：</label><form:input path="idNumber" htmlEscape="false" maxlength="50" class="input-medium"/>
		<label>门店名称 ：</label>
		<form:select path="id" class="js-example-basic-single">
			<form:option value="">全部</form:option>
			<c:forEach items="${JiuStoreList}" var="jiuStore">
                   <form:option value="${jiuStore.id}">${jiuStore.name}</form:option>
			</c:forEach>
       	</form:select>
       	
       	<label>审核状态：</label>
          <form:select path="examineState"   style="WIDTH: 130px">
                     <form:option value="">全部</form:option>
                         <form:option value="0">未审核</form:option>
                         <form:option value="1">已审核</form:option>
         </form:select>
         
         
		</br>
		<label>注册时间 ：</label>
		
				<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${jiuStore.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> -至-
						
				<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${jiuStore.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> 
		
		&nbsp;<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="javascript:search()"/>
		<c:set var="isExcel" value="${fn:indexOf(fns:getUser().roleIdList, '12') == -1}" scope="page"/>
		<c:if test="${isExcel }">	<!-- 平台出纳  无权导出 -->
			&nbsp;<input class="btn btn-primary" type="button" value="导出" onclick="javascript:excel()"/>
		</c:if>
	</form:form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered ">
		<thead><tr>
		<th>门店名称</th>
		<th>管理员</th>
		<th>提现账户微信</th>
		<th>提现账户姓名</th>
		<th>联系电话</th>
		<th>门店积分</th>
		<th>门店地址</th>
		<th>审核状态</th>
		<th>注册时间</th>
		<th>绑定的厂家</th>
		<th>认证姓名</th>
		<th>身份证号</th>
		<th>开户行</th>
		<th>银行卡号</th>
		<shiro:hasPermission name="jiujiu:jiuStore:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="jiuStore">
			<tr>
				<td>${jiuStore.name}</td>
				<td id="guan${jiuStore.id}">${jiuStore.memberName}</td>
				<td id="tiwei${jiuStore.id}">${jiuStore.tiMemberName}</td>
				<td id="tizhen${jiuStore.id}">${jiuStore.tiRealName}</td>
				<td>${jiuStore.phone}</td>
				<td>${jiuStore.point}</td>
				<td>${jiuStore.address}</td>
				<td id="s${jiuStore.id}">
					<c:choose>
					    <c:when test="${jiuStore.examineState eq 0}">
					      	未审核
					    </c:when>
					    <c:when test="${jiuStore.examineState eq 1}">
					      	已通过
					    </c:when>
					    <c:when test="${jiuStore.examineState eq 2}">
					      	未通过
					    </c:when>
					    <c:otherwise>
					    </c:otherwise>
					</c:choose>
				
				</td>
				<td><fmt:formatDate value="${jiuStore.createTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<td>${jiuStore.factoryName}</td>
				<td>${jiuStore.realName}</td>
				<td>${jiuStore.idNumber}</td>
				<td>${jiuStore.openingBank}</td>
				<td>${jiuStore.bankCardNumber}</td>
				<shiro:hasPermission name="jiujiu:jiuStore:edit"><td>
				
					<div class="btn-toolbar" style="margin: 0;width: 400px;">
						<c:if test="${jiuStore.examineState eq 0}">
							<a class="btn btn-success" href="javascript:auditing(${jiuStore.id})">审核</a>
	                    </c:if>
    				<%-- <a class="btn btn-success" href="${ctx}/jiujiu/jiuStore/form?id=${jiuStore.id}">修改</a> --%>
    				<div class="btn-group">
							<button class="btn btn-success">管理组 </button>
							<button class="btn btn-success dropdown-toggle" data-toggle="dropdown">
						    	<span class="caret"></span>
							</button>
							<ul class="dropdown-menu">
								<li><a href="javascript:administrators(${jiuStore.id})">管理员设置</a></li>
								<li><a href="${ctx}/jiujiu/jiuDesign?storeId=${jiuStore.id}">传图设计师</a></li>
								<li><a href="${ctx}/jiujiu/jiuFinance?storeId=${jiuStore.id}">财务</a></li>
								<li><a href="javascript:tixian(${jiuStore.id})">设置提现账户</a></li>
							</ul>
						</div>
					 <%-- <a class="btn btn-danger" href="${ctx}/jiujiu/jiuStore/delete?id=${jiuStore.id}" onclick="return confirmx('确认要删除该门店吗？', this.href)">删除</a> --%>
					</div>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>
